<?php
/**
 * Created by PhpStorm.
 * User: geyouwen
 * Date: 16/9/7
 * Time: 下午1:58
 */

namespace Superadmin\Model;


use Think\Model;

class LevelModel extends Model
{

   //查询所有等级
   public function level()
   {
       $data = $this->select();
       return $data;
   }

    //根据积分获得等级名
    public function getLevel($point)
    {
        $where = 'score <= '.$point;
        $order = 'score desc';
        $data  = $this->where($where)->order($order)->find();
        return $data;
    }


    public function getLevelId($point)
    {
       $level = $this->getLevel($point);
        return $level ? $level['id'] : 0;
    }
}